<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <meta name="description" content="" />
    <meta name="author" content="" />
    <title>{{blogname}}博客</title>
    <link rel="icon" type="image/x-icon" href="/static/assets/favicon.ico" />
    <!-- Font Awesome icons (free version)-->
    <script src="https://use.fontawesome.com/releases/v5.15.3/js/all.js" crossorigin="anonymous"></script>
    <!-- Google fonts-->
    <link href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" rel="stylesheet"
        type="text/css" />
    <link
        href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800"
        rel="stylesheet" type="text/css" />
    <!-- Core theme CSS (includes Bootstrap)-->
    <link href="/static/css/styles.css" rel="stylesheet" />
</head>

<body>
    <!-- Navigation-->
    <nav class="navbar navbar-expand-lg navbar-light" id="mainNav">
        <div class="container px-4 px-lg-5">
            <a class="navbar-brand" href="index">{{blogname}}博客</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive"
                aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
                菜单
                <i class="fas fa-bars"></i>
            </button>
            <div class="collapse navbar-collapse" id="navbarResponsive">
                <ul class="navbar-nav ms-auto py-4 py-lg-0">
                    {% for i in labels %}
                    <li class="nav-item"><a class="nav-link px-lg-3 py-3 py-lg-4" href="{{i}}"
                            style="font-size: 20px;">{{labels[i]}}</a></li>
                    {% endfor %}
                </ul>
            </div>
        </div>
    </nav>
    <!-- Page Header-->
    <header class="masthead" style="background-image: url('/static/assets/img/contact-bg.jpg')">
        <div class="container position-relative px-4 px-lg-5">
            <div class="row gx-4 gx-lg-5 justify-content-center">
                <div class="col-md-10 col-lg-8 col-xl-7">
                    <div class="page-heading">
                        <h1>{{blogname}}文章上传</h1>
                    </div>
                </div>
            </div>
        </div>
    </header>
    <!-- Main Content-->
    <main class="row row-cols-1 row-cols-md-3 g-4  justify-content-center">
        <fieldset>
            <legend>发布文章</legend>
            <div class="mb-3">
                <label for="TextInput" class="form-label">标题</label>
                <input type="text" id="ArticleTitle" class="form-control" placeholder="文章标题">
            </div>
            <div class="mb-3">
                <label for="Select" class="form-label">内容</label>
                <textarea class="form-control" id="ArticleContent" aria-label="With textarea"></textarea>
            </div>
            <div class="mb-3">
                <label for="TextInput" class="form-label">大图</label>
                <input type="file" id="img" class="form-control">
            </div>
            <button type="button" id="upload" class="btn btn-primary">上传</button>
        </fieldset>
    </main>
    <!-- Footer-->
    <footer class="border-top">
        <div class="container px-4 px-lg-5">
            <div class="row gx-4 gx-lg-5 justify-content-center">
                <div class="col-md-10 col-lg-8 col-xl-7">
                    <ul class="list-inline text-center">
                        <li class="list-inline-item">
                            <a href="#!">
                                <span class="fa-stack fa-lg">
                                    <i class="fas fa-circle fa-stack-2x"></i>
                                    <i class="fab fa-twitter fa-stack-1x fa-inverse"></i>
                                </span>
                            </a>
                        </li>
                        <li class="list-inline-item">
                            <a href="#!">
                                <span class="fa-stack fa-lg">
                                    <i class="fas fa-circle fa-stack-2x"></i>
                                    <i class="fab fa-facebook-f fa-stack-1x fa-inverse"></i>
                                </span>
                            </a>
                        </li>
                        <li class="list-inline-item">
                            <a href="#!">
                                <span class="fa-stack fa-lg">
                                    <i class="fas fa-circle fa-stack-2x"></i>
                                    <i class="fab fa-github fa-stack-1x fa-inverse"></i>
                                </span>
                            </a>
                        </li>
                    </ul>
                    <div class="small text-center text-muted fst-italic">Copyright &copy; {{blogname}}博客 2023</div>
                </div>
            </div>
        </div>
    </footer>
    <!-- Bootstrap core JS-->
    <script src="/static/js/bootstrap.bundle.min.js"></script>
    <!-- Core theme JS-->
    <script src="/static/js/scripts.js"></script>
    <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script>
    <script src="https://www.jq22.com/jquery/bootstrap-3.3.4.js"></script>
    <script src="/static/jquery-validation/jquery.validate.min.js"></script>
    <script>
        $("#upload").click(function () {
            console.log(123);
            var formData = new FormData();
            formData.append("ArticleTitle", $("#ArticleTitle").val());
            formData.append("ArticleContent", $("#ArticleContent").val());
            formData.append("Img", $('#img')[0].files[0]);
            console.log(formData);
            $.ajax({
                type: "POST",
                url: "/article/add",
                data: formData,
                processData: false, // 使数据不做处理
                contentType: false, // 不要设置Content-Type请求头
                success: function (res) {
                    if (res.code == 200) {
                        alert(res.message);
                    } else {
                        alert(res.message)
                    }

                }
            });
        })
    </script>
</body>

</html>